﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace android_charge.compent
{
    public partial class CustomControl1 : Button
    {
        public CustomControl1()
        {
            InitializeComponent();
            this.FlatStyle = FlatStyle.Flat;
            this.FlatAppearance.BorderSize = 0;
            this.BackColor = Color.Transparent;
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);

            // 获取图形对象
            Graphics g = pe.Graphics;

            // 清除按钮矩形区域的背景
            g.Clear(this.Parent.BackColor);

            // 定义圆形的画刷，可以自定义颜色
            Brush brush = new SolidBrush(Color.Gray);

            // 填充一个圆形 (椭圆形的边界框)
            g.FillEllipse(brush, 0, 0, this.Width, this.Height);
        }

        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            // 保持按钮为圆形，设置宽度和高度一致
            this.Width = this.Height;
        }
    }
}
